Color-Component Values, Color Values, and Colors
Each of the color spaces described in this chapter requires one or more numeric values in a particular format to specify a color. This section describes the data types and structures with which QuickDraw GX describes colors in its color spaces.Each dimension, or component, in a color space has a color-component value. In the fundamental, unpacked QuickDraw GX color spaces--those with 16 bits per component--each color-component value is of type
gxColorValue
:
typedef unsigned short gxColorValue;A color-component value can vary from 0 to 65,535 (0xFFFF), although the numerical interpretation of that range is different for different color spaces, as has been noted in Table 4-1 through Table 4-7. In most cases, color-component intensities are interpreted numerically as varying between 0 and 1.0; for that reason, QuickDraw GX provides the constantgxColorValue1
to represent 0xFFFF.Depending on the color space used, one, two, three, or four color-component values combine to make a color value. A color value is a structure; it is the complete specification of a color in a given color space. QuickDraw GX supports 13 color-value formats, representing the fundamental 16-bits-per-component color spaces; all color operations in memory use one of those formats. The color-value formats are described in the section "Color Values" beginning on page 4-50. For example, an RGB color value has this format:
struct gxRGBColor{ gxColorValue red; gxColorValue green; gxColorValue blue; };This is exactly the storage format for colors ingxRGBSpace
. However, colors stored ingxRGB16Space
orgxRGB32Space
have a packed storage format, and need to be converted togxRGBColor
format when they are used. QuickDraw GX takes care of this for you; as far as your application is concerned, you can always manipulate colors in the color space you have specified.A color value plus a specification of the color space it belongs to (plus an
optional reference to a color profile to use for color matching) constitute a color in QuickDraw GX. A color is defined by thegxColor
structure:
struct gxColor{ gxColorSpace space; gxColorProfile profile; union { struct gxCMYKColor cmyk; struct gxRGBColor rgb; struct gxRGBAColor rgba; struct gxHSVColor hsv; struct gxHLSColor hls; struct gxXYZColor xyz; struct gxYXYColor yxy; struct gxLUVColor luv; struct gxLABColor lab; struct gxYIQColor yiq; gxColorValue gray; struct gxGrayAColor graya; unsigned short pixel16; unsigned long pixel32; struct gxIndexedColor indexed; gxColorValue component[4]; } element; };EachgxColor
structure holds the specification of a single color. Note that, besides the basic color-value formats such asgxRGBColor
andgxXYZColor
, a QuickDraw GX color can contain a 16-bit or 32-bit pixel value or an indexed color value, and you can also access the color as an array of color-component values. Each of the color values in theelement
union of the gxColor structure is described in the section "The Color Structure" beginning on page 4-53.